import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../screens/main_tabs.dart';
import '../screens/post_detail_page.dart';
import '../screens/profile_page.dart';
import '../screens/video_list_page.dart';
import '../screens/chat_list_page.dart';
import '../screens/video_player_page.dart'; // 添加视频播放页面导入
import '../screens/user_profile_page.dart'; // 添加用户资料页面导入
// 导入其他页面
// import '../screens/settings_page.dart';
// import '../screens/coin_list_page.dart';
// import '../screens/my_posts_page.dart';
// import '../screens/feedback_page.dart';

class AppRoutes {
  static const String home = '/';
  static const String postDetail = '/postDetail';
  static const String profile = '/profile';
  static const String videoList = '/videoList';
  static const String chatList = '/chatList';
  static const String videoPlayer = '/videoPlayer'; // 添加视频播放器路由常量
  
  // 添加用户详情页路由常量
  static const String userProfile = '/user-profile';
  
  // 添加新的路由常量
  static const String settings = '/settings';
  static const String coinList = '/coinList';
  static const String myPosts = '/myPosts';
  static const String feedback = '/feedback';

  static List<GetPage> pages = [
    GetPage(name: home, page: () => const MainTabs()),
    GetPage(
      name: postDetail, 
      page: () {
        final arguments = Get.arguments;
        if (arguments != null && arguments is Map && arguments.containsKey('post')) {
          return PostDetailPage(post: arguments['post']);
        }
        return Scaffold(
          appBar: AppBar(title: const Text('错误')),
          body: const Center(child: Text('帖子信息缺失')),
        );
      },
    ),
    GetPage(
      name: userProfile,
      page: () {
        final arguments = Get.arguments;
        if (arguments != null && arguments is Map) {
          return UserProfilePage(
            userId: arguments['userId'] ?? '',
            userNickname: arguments['userNickname'] ?? '',
            userAvatarUrl: arguments['userAvatarUrl'] ?? '',
          );
        }
        return Scaffold(
          appBar: AppBar(title: const Text('错误')),
          body: const Center(child: Text('用户信息缺失')),
        );
      },
    ),
    GetPage(
      name: videoPlayer, 
      page: () {
        final arguments = Get.arguments;
        if (arguments != null && arguments is Map && arguments.containsKey('videoUrl')) {
          return VideoPlayerPage(videoUrl: arguments['videoUrl']);
        }
        return const VideoPlayerPage(videoUrl: '');
      }
    ),
    GetPage(name: profile, page: () => const ProfilePage()),
    GetPage(name: videoList, page: () => const VideoListPage()),
    GetPage(name: chatList, page: () => const ChatListPage()),
    
    // 添加新的路由页面
    // 如果页面尚未创建，可以使用临时页面
    GetPage(name: settings, page: () => Scaffold(
      appBar: AppBar(title: const Text('设置')),
      body: const Center(child: Text('设置页面开发中')),
    )),
    GetPage(name: coinList, page: () => Scaffold(
      appBar: AppBar(title: const Text('我的金币')),
      body: const Center(child: Text('金币页面开发中')),
    )),
    GetPage(name: myPosts, page: () => Scaffold(
      appBar: AppBar(title: const Text('我的帖子')),
      body: const Center(child: Text('我的帖子页面开发中')),
    )),
    GetPage(name: feedback, page: () => Scaffold(
      appBar: AppBar(title: const Text('系统反馈')),
      body: const Center(child: Text('反馈页面开发中')),
    )),
  ];
}

class Routes {
  static const HOME = '/home';
  static const LOGIN = '/login';
  static const REGISTER = '/register';
  static const PROFILE = '/profile';
  static const CHAT = '/chat'; // 添加聊天页面路由
  // 其他路由
}